home *** CD-ROM | disk | FTP | other *** search
- Path: rover.ucs.ualberta.ca!alberta!diego
- From: diego@cs.ualberta.ca (Diego Novillo)
- Newsgroups: comp.lang.c++
- Subject: Problems extending an existing class library
- Date: 7 Feb 1996 17:29:56 GMT
- Organization: Computing Science, U of Alberta, Edmonton, Canada
- Message-ID: <4fanik$ltq@scapa.cs.ualberta.ca>
- NNTP-Posting-Host: charron.cs.ualberta.ca
-
- We are developing a compiler using a code restructuring tool that
- provides classes for all the basic components of a program: Functions,
- Statements, Expressions, Types, Symbols and their corresponding
- sub-classes.
-
- Now, we would like to create new sub-classes to specialize the existing
- classes and the first impulse was to inherit from them because the
- specialization was clearly an "is-a" relation.
-
- This system parses the source code and builds a special file which
- contains the annotated parse tree of the program. All the objects reside
- on this binary file and the memory objects are just pointers to
- different portions of the file. As a result, the memory objects are just
- pointers to C data structures which hold the real implementation of the
- system (This class library is a wrapper around the old C
- implementation).
-
- Since the base classes don't have constructors, we cannot build our own
- memory objects because our constructors cannot call the base class
- constructors to initialize the parent class.
-
- We got around the problem by using a "has-a" relation. That is, each of
- our classes has a pointer to the "parent" class and each time we create
- a new object we just initialize this pointer.
-
- We don't like this option too much, but we don't see another way around
- the problem. Modifying the original classes is not an option either, the
- system is large and we don't have much time to mess around with it.
-
- Does anyone have a suggestion on how to work around this problem? Has
- anyone faced this problem before? How did you solve it?
-
- Thank you.
-
- Diego.
-
-
-